package com.itheima.user.controller;

import com.itheima.user.pojo.User;
import com.itheima.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;

/**
 * @作者 itcast
 * @创建日期 2020/12/1 10:29
 **/
@RestController
@RequestMapping("user")
public class UserController {
    @Value("${server.port}")
    int port;

    @Autowired
    UserService userService;

    @GetMapping("{id}") // @RequestParams     //@RequestBody
    public User findById(@PathVariable("id") String id, HttpServletRequest request){
        System.out.println("当前用户服务端口==>"+port);
        String name = request.getHeader("name");
        System.out.println("请求头name的值==>"+name);
        User byId = userService.findById(id);
        byId.setEmail("当前用户服务端口==>"+port);
        return byId;
    }
}
